//
//  TTDianpuTemplateCollectionViewCell.m
//  TaoTuo
//
//  Created by admin on 2019/11/9.
//  Copyright © 2019 admin. All rights reserved.
//

#import "TTDianpuTemplateCollectionViewCell.h"
#import <UIImageView+WebCache.h>

@interface TTDianpuTemplateCollectionViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UIButton *btn;


@end

@implementation TTDianpuTemplateCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.imageView.layer.cornerRadius = 5;
    self.imageView.layer.masksToBounds = YES;
    
    
}


- (IBAction)clickBtn:(UIButton *)sender {
    
    sender.selected = YES;
    self.model.isSelect = YES;
    
    if ([self.delegate respondsToSelector:@selector(selectedItem:model:)]) {
        [self.delegate selectedItem:self model:self.model];
    }
    
}


- (void)setModel:(TTDianpuTempleteModel *)model
{
    _model = model;
    
    NSString *string = [model.TemplateImg urlEncode];
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:string] placeholderImage:[UIImage imageNamed:@"dianpumuban"] options:SDWebImageRetryFailed];
    
    
    self.btn.enabled = model.State != 0;
    self.btn.selected = model.isSelect;
}

@end
